 
package com.xbongbong.paas.domain.dao;

import com.xbongbong.paas.domain.entity.PaasFormExplainEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormExplainEntityExt;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;


/**
* @author autoGen
* @time 2018-08-13 10:37:25
*/
@Repository
@Mapper
public interface PaasFormExplainDao {

	 
	Integer insert(PaasFormExplainEntity paasFormExplain);
	Integer update(PaasFormExplainEntity paasFormExplain);

	/**
	 * 批量插入
	 * @param paasFormExplainList 插入信息
	 * @return 返回实体列表
	 */
	Integer insertBatch(@Param("list") List<PaasFormExplainEntity> paasFormExplainList);
	
	Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);

	PaasFormExplainEntity getByKey(@Param("key") Integer key, @Param("corpid") String corpid);

	PaasFormExplainEntity getWorkOrderExplainByFormId(@Param("formId") Integer formId, @Param("corpid") String corpid);

	/**
	 * 根据菜单获取单条数据
	 * @param menuId 菜单id
	 * @param corpid 公司id
	 * @return
	 */
	PaasFormExplainEntity getByMenuId(@Param("menuId") Long menuId, @Param("corpid") String corpid);

	/**
	 * 根据菜单id和业务类型获取单条数据
	 * @param menuId 菜单id
	 * @param corpid 公司id
	 * @param businessType 业务类型
	 * @return
	 */
	PaasFormExplainEntity getByMenuIdAndBusinessType(@Param("menuId") Integer menuId, @Param("corpid") String corpid, @Param("businessType") Integer businessType);
	/**
	 * 根据表单获取单条数据
	 * @param formId 表单id
	 * @param corpid 公司id
	 * @return
	 */
	PaasFormExplainEntity getByFormId(@Param("formId") Long formId, @Param("corpid") String corpid);

	
	List<PaasFormExplainEntity>  findEntitys(@Param("param") Map<String, Object> param, @Param("tableName") String tableName);
	Integer getEntitysCount(@Param("param") Map<String, Object> param);

    PaasFormExplainEntity getByBusinessType(@Param("businessType") Integer businessType, @Param("corpid") String corpid, @Param("tableName") String tableName);

	PaasFormExplainEntity getByBusinessType4Distributor(@Param("businessType") Integer businessType, @Param("corpid") String corpid, @Param("distributor") Integer distributor, @Param("tableName") String tableName);

	PaasFormExplainEntity getByBusinessTypeNoEnable(@Param("businessType") Integer businessType, @Param("corpid") String corpid);

	PaasFormExplainEntityExt getExtByBusinessType(@Param("businessType") Integer businessType, @Param("corpid") String corpid);

	PaasFormExplainEntity getSystemDefaultExplain(@Param("businessType") Integer businessType, @Param("tableName") String tableName);

    List<String> getCorpidList();

    Integer updateByFormId(@Param("formId") Long formId, @Param("corpid") String corpid, @Param("enable") Integer enable);

	/**
	 * 慎用！！！如果分库后则强制不能使用该方法！！！
	 * 因为，该方法没有限制corpid（专门给资金管理改造一期使用：批量更新线上的回款单explains）
	 * 批量更新表单解释：回款单的explains
	 *
	 * @param list 表单解释列表
     * @return java.lang.Integer
	 * @author 徐俊杰
	 * @date 2019/12/17 14:51
	 * @since v1.0
	 */
	Integer updateBatchExplains(@Param("list") List<PaasFormExplainEntity> list);

	Integer updateBatchExplainsByCorpid(@Param("list") List<PaasFormExplainEntity> list, @Param("corpid") String corpid);

    List<PaasFormExplainEntity> getListForUpdateProduct(@Param("corpid") String corpid, @Param("businessTypeList") List<Integer> businessTypeList);

    PaasFormExplainEntity getOriStockForm();

	/**
	 * 批量更新
	 *
	 * @param list
	 * @param corpid
	 */
	void updateBatch(@Param("list") List<PaasFormExplainEntity> list, @Param("corpid") String corpid);

	/**
	 * 批量删除
	 * @param list 主键id集合
	 * @param corpid
	 * @author xingxing.xiao
	 */
	Integer deleteBatch(@Param("list") List<Long> list, @Param("corpid") String corpid);


	PaasFormExplainEntity getWorkReportDefaultAllListExplain();
    Integer deleteBatchByMenuId(@Param("list") List<Long> list, @Param("corpid") String corpid);

    /**
     * 得到符合条件最大的id
     * @param param
     * @return java.lang.Long
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
	Long getMaxId(@Param("param") Map<String, Object> param);
}